package com.haoke.comment.controller;


import com.haoke.comment.service.CommentService;
import com.haoke.commons.vo.HaokeResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author yue13
 * <p>
 * 商品评论控制器
 */
@RestController
@CrossOrigin
public class CommentController {
    @Autowired
    private CommentService commentService;

    /**
     * 新增订单评论
     * @param orderId 订单主键
     * @param feelback 评论内容
     * @return
     */
    @PostMapping("/feelback")
    public HaokeResult feelback(String orderId, String feelback){
        return commentService.fellback(orderId, feelback);
    }

    /**
     * 根据商品主键查询商品评论
     *
     * @param itemId
     * @return
     */
    @GetMapping("/comment")
    public HaokeResult getCommentByItemId(
            @RequestParam(value = "id") String itemId,
            int page,
            @RequestParam(defaultValue = "5") int rows) {

        return commentService.findCommentByItemId(itemId, page, rows);
    }


}
